<template>
  <div>
    <FormPanel ref="from" :list="formList" @formChange="changeHandle" :isSubmitBtn="false" :collapse="false" labelWidth="110" />
    <BreakSpace label='操作记录' />
    <FilterTable
      ref="table"
      :columns="columns"
      :dataSource="tableList"
      :isSelectColumn="false"
      height='auto'
      :onColumnsChange="columns => this.columns = columns"
    >

    </FilterTable>
    <div style="height:47px;"></div>

    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <el-button @click="closeDrawer(1)">关 闭</el-button>
    </div>
  </div>
</template>
<script>
import { dictionary } from '@/utils/dictMixin';
import {getflowList,getDealerUser} from '@/api/index.js'
import {getRecordLockedLog} from '@/api/dealerSale/InventoryManagement/InventoryManagement';
export default {
  data(){
    return{
      formList:this.createdFrom(),
      issearch:false,
      fetchApi:()=>{},
      fetchParams:{},
      columns:this.createdTable(),
      tableList:[]
    }
  },
  props:['rowData'],
  components:{
  },
  mixins:[dictionary],
  created(){
    this.init()
    this.getUser()
    this.getRecordLockedLog(this.rowData)
  },
  methods:{
    createdFrom(){
      return [
        {
          type: 'BREAK_SPACE',
          label: '锁定信息',
        },

        {
          type: 'TEXT_AREA',
          label: '锁定备注',
          fieldName: 'lockRemark',
          placeholder: '请输入',
          selfCols:3,
          disabled:true
        },
      ]
    },
    createdTable(){
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '操作人',
          dataIndex: 'createdBy',
          sorter: true,
          filter: true,
          ilterType: 'checkbox',
          filterItems: [],
          editType: 'select',
          editItems: []
        },
        {
          title: '操作时间',
          dataIndex: 'createdAt',
          sorter: true,
          filter: true,
          filterType: 'date-range',
        },
        {
          title: '操作类型',
          dataIndex: 'lockType',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: [{text:'车辆锁定',value:10041001},{text:'车辆解锁',value:10041002}],
          render: (p) => {
            return <span>{p.row.lockType==10041001?'车辆锁定':'车辆解锁'}</span>;
          },
        },
        {
          title: '操作后状态',
          dataIndex: 'vehicleStatus',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: this.createDictList('6040'),
          render: (p) => {
            return <span>{this.createDictText(p.row.vehicleStatus, '6040')}</span>;
          },
        },
        {
          title: '操作备注',
          dataIndex: 'remark',
          sorter: true,
          filter: true,
          filterType: 'input',

        },
      ]
    },
    init(){
      let str=this.rowData.lockRemark
      console.log(this.rowData,str,'str')
      this.formList.map(x=>{
        if(x.fieldName=='lockRemark'){
          x.initialValue=str;
        }
      })
    },
    changeHandle(val){

    },
    closeDrawer(type){
      this.$emit('close')
    },
    async getUser(){
      let res=await getDealerUser()
      let empList = res.data.map(x => ({ text: x.employeeName, value: x.userId }));
      this.columns.find(item => item.dataIndex === 'createdBy').editItems = empList; //操作姓名
      this.columns.find(item => item.dataIndex === 'createdBy').filterItems = empList;
    },
    async getRecordLockedLog(data){
      let res=await getRecordLockedLog({vehicleId:data.vehicleId})
      this.tableList=res.data||[]

    },

  }
}
</script>
